package io.vincentwinner.systeminfoapi.dao.impl;

import io.vincentwinner.systeminfoapi.dao.ICentralProcessUnitDao;
import io.vincentwinner.toolset.os.CPU;
import io.vincentwinner.toolset.os.Computer;
import org.springframework.stereotype.Repository;

/**
 * @see ICentralProcessUnitDao
 */
@Repository("cpuDao")
public class CentralProcessUnitDaoImpl implements ICentralProcessUnitDao {

    private final CPU cpu = Computer.getCPU();
    private final CPU.CPUHardWareInfo hardInfo = cpu.getCPUInfo();

    @Override
    public String getVendor() {
        return hardInfo.getVendor();
    }

    @Override
    public String getCPUName() {
        return hardInfo.getName();
    }

    @Override
    public String getFamily() {
        return hardInfo.getFamily();
    }

    @Override
    public Integer getLogicalCoreNum() {
        return hardInfo.getLogicalCoreNum();
    }

    @Override
    public Integer getPhysicalCoreNum() {
        return hardInfo.getPhysicalCoreNum();
    }

    @Override
    public String getModel() {
        return hardInfo.getModel();
    }

    @Override
    public String getStepping() {
        return hardInfo.getStepping();
    }

    @Override
    public Long getVendorFreq() {
        return hardInfo.getVendorFreq();
    }

    @Override
    public Long getMaxFreq() {
        return hardInfo.getMaxFreq();
    }

    @Override
    public Boolean isCpu64Bit() {
        return hardInfo.is64Bit();
    }

    @Override
    public Double getUsage() {
        return cpu.usage();
    }

}
